/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chiabai;

/**
 *
 * @author Oho
 */
import java.awt.*;
import javax.swing.*;
/**
 * Simple program that loads, rotates and displays an image.
 * Uses the file Duke_Blocks.gif, which should be in
 * the same directory.
 * 
 * @author MAG
 * @version 20Feb2009
 */

public class RotateImage extends JPanel implements  Runnable{

    // Declare an Image object for us to use.
    Image image;
    int x=0,y=0;
    // Create a constructor method
    public RotateImage(){
       super();
       // Load an image to play with.
       image = Toolkit.getDefaultToolkit().getImage("C:/abc/1.jpg");
    }
  
    public void paintComponent(Graphics g){
         Graphics2D g2d=(Graphics2D)g; // Create a Java2D version of g.
         g2d.translate(200, 0); // Translate the center of our coordinates.
         g2d.rotate(1.57);  // Rotate the image by 1 radian.
         g2d.drawImage(image, x, y, 200, 200, this);
    }

    public static void main(String arg[]){
       JFrame frame = new JFrame("RotateImage");
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frame.setSize(600,400);
       
       RotateImage panel = new RotateImage();
       
       frame.setContentPane(panel);  
       frame.setVisible(true);  
    }

    @Override
    public void run() {
        while(true)
        {
            x++;
            y++;
        }
    }
}